Skip to content

Add a staking lock extension function allowing stakers to extend their lock period before it expires - #823

Open
Godfrey-Delight wants to merge 13 commits into
accesslayerorg:mainfrom
Godfrey-Delight:feat/stake-extend-unlock-ledger
Open

Add a staking lock extension function allowing stakers to extend their lock period before it expires#823
Godfrey-Delight wants to merge 13 commits into
accesslayerorg:mainfrom
Godfrey-Delight:feat/stake-extend-unlock-ledger

Conversation

@Godfrey-Delight

@Godfrey-Delight Godfrey-Delight commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds stake_extend(key_id: BytesN<32>, additional_ledgers: u32), allowing a wallet with an active stake to push back its unlock_ledger and continue earning rewards without unstaking and re-staking. Introduces StakePosition storage keyed by wallet and BytesN<32> key ID, validates that the caller has an active stake on the given key (panicking with the new NoStakeFound error otherwise), enforces that the resulting unlock_ledger is no more than 180 days out from the current ledger (panicking with the new LockTooLong error otherwise), bumps the TTL on the staking_positions entry after a valid extension, and emits a stake_extended event carrying wallet, key ID, old unlock_ledger, and new unlock_ledger. Takes an explicit wallet argument rather than relying on an invoker lookup, since this Soroban SDK does not expose Env::invoker(). Changes are in lib.rs and events.rs.

Closes #800

Changes

  • Added wallet/key-based StakePosition storage.
  • Added stake_extend(wallet, key_id, additional_ledgers).
  • Enforces a maximum unlock time of 180 days from the current ledger.
  • Returns NoStakeFound when no active stake exists.
  • Returns LockTooLong when the limit is exceeded.
  • Updates the unlock ledger and bumps persistent storage TTL.
  • Emits stake_extended with wallet, key ID, and old/new unlock ledgers.

Testing

  • cargo fmt --all -- --check
  • cargo clippy --workspace --all-targets -- -D warnings
  • cargo test --workspace

Checklist

  • Linked issue or backlog item: none provided.
  • Added tests for valid extension, NoStakeFound, LockTooLong, event emission, and TTL bump.
  • Reviewed storage changes: the new StakingPosition key is additive; no existing keys are modified.
  • Added a new stake_extended event with stable topic and payload field ordering.
  • Updated documentation for the new public interface and storage behavior.
  • Scope is limited to staking extension behavior.

@drips-wave

drips-wave Bot commented Aug 28, 2026

Copy link
Copy Markdown

@Godfrey-Delight Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@Godfrey-Delight
Godfrey-Delight force-pushed the feat/stake-extend-unlock-ledger branch from c0cd2db to 4963f19 Compare September 1, 2026 06:54
@Chucks1093

Copy link
Copy Markdown
Member

❌ CI Failed — verify (Contracts CI)

The verify check is failing on this PR.

Likely causes:

  • New storage or function definition doesn't match the existing interface
  • cargo fmt was not run before pushing
  • Missing error handling or require! macro missing an error variant

Steps to fix:

  1. Run cargo build and read the error output
  2. Run cargo fmt --all and commit
  3. Push

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a staking lock extension function allowing stakers to extend their lock period before it expires

2 participants